#include "vroute_PortManager.hpp"
#include "vroute_port_list.hpp"

namespace vroute_stack
{
    CPortMgr* CPortMgr::_instance = nullptr;
    
    CPortMgr* CPortMgr::getInstance()
    {
        if (nullptr == _instance)
        {
            _instance = new CPortMgr();
        }
        return _instance;
    }

    void CPortMgr::releaseInstnce()
    {
        ReleaseInsMaic(_instance)
    }

    CPortMgr::CPortMgr()
    {
        m_port = portListMgr::getInstance();
    }

    CPortMgr::~CPortMgr()
    {
        portListMgr::releaseInstance();
        m_port = nullptr;

    }

    int CPortMgr::init(SystemStartType type)
    {
        return m_port->Init(type);
    }

    int CPortMgr::getOepnPortCount()
    {
        return max_port_regist_count;
    }

    int CPortMgr::setValue(unsigned char socketIndex, portItemKey key, const void* value)
    {
        return m_port->setKV(socketIndex, key, value);
    }

    int CPortMgr::getValue(unsigned char socketIndex, portItemKey key, void*& value)
    {
        return m_port->getKV(socketIndex, key, value);
    }

    int CPortMgr::getOutPutPort(unsigned char socketIndex, unsigned char& outIndex)
    {
        return m_port->getOutPutPort(socketIndex, outIndex);
    }

    int CPortMgr::getOutputPortAddr(const Node& nextaddr, unsigned char& outIndex)
    {
        return m_port->getOutPutPortAddr(nextaddr, outIndex);
    }

    int CPortMgr::getOutPutPortByInIndex(unsigned char inIndex, unsigned char& outIndex)
    {
        return m_port->getOutPutPortByInIndex(inIndex, outIndex);
    }

    int CPortMgr::canclePort(int socketIndex)
    {
        return m_port->canclePort(socketIndex);
    }
}